<?php

namespace App\JsonRpc;

use App\Model\Gift;
use App\Services\Gift\GiftService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\RpcServer\Annotation\RpcService;

#[RpcService(name: "RGiftService", server: "jsonrpc-http", protocol: "jsonrpc-http", publishTo: "nacos")]
class RGiftService implements RGiftServiceInterface
{
    #[Inject]
    protected GiftService $giftService;

    public function list($userInfo, $params)
    {
        // $userInfo['uid'] = 1000048;
        // $userInfo['sex'] = 2;
        // $userInfo['guild_num'] = '';
        // $userInfo['send_gift_rate'] = 0.4;
        // $params['user_id'] = 1000049;
        // TODO: Implement list() method.
        return $this->giftService->list($userInfo, $params);
    }

    public function create($params)
    {
        $params = [
            'name' => $params['name'],
            'en_name' => $params['en_name'],
            'hk_name' => $params['hk_name'],
            'price' => 100,
            'price2' => 100,
            'img' => $params['img'],
            'status' => 1,
            'ctime' => time()
        ];
        return Gift::create($params);
    }
}